package com.wy.fragments;

import com.wy.music_player.Login;
import com.wy.music_player.R;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class PersonInfoFragment extends Fragment{

	private String TAG = "PersonInfoFragment";

	View view;
	Button logout,updateinfo;
	TextView tv_username,tv_sex,tv_country;

	String username,sex,country;

	public PersonInfoFragment() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		view = inflater.inflate(R.layout.person_layout, container, false);
		initInfo(getArguments());
		bindViews();

		// 退出登录
		logout.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Log.i(TAG, "logout.onClick");
				Intent it = new Intent(getActivity().getApplication(), Login.class);
				startActivity(it);
				getActivity().finish();
			}
		});
		return view;
	}

	public void bindViews(){
		logout = (Button) view.findViewById(R.id.logout);
		tv_sex = (TextView) view.findViewById(R.id.sex);
		tv_username = (TextView) view.findViewById(R.id.username);
		tv_country = (TextView) view.findViewById(R.id.country);

		tv_username.setText(username);
		tv_sex.setText(sex);
		tv_country.setText(country);
	}
	public void initInfo(Bundle bundle){
		username = bundle.getString("username");
		sex = bundle.getString("sex");
		country = bundle.getString("country");
	}
}
